package com.collection.common.base;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


import org.apache.commons.fileupload.ProgressListener;

import com.collection.dto.UploadFileState;

public class UploadFileListener implements ProgressListener {

	 private HttpSession session;  
	     
	  public UploadFileListener(HttpServletRequest request) {  
          session = request.getSession();  
          UploadFileState uploadFileState = new UploadFileState();  
          session.setAttribute("uploadFileState", uploadFileState);  
   }  
    @Override  
   public void update(long readedBytes, long totalBytes, int currentItem) {  
        // TODO Auto-generated method stub  
          System.out.println("update:"+readedBytes+";"+totalBytes+";"+currentItem);  
            
          UploadFileState uploadFileState = (UploadFileState) session.getAttribute("uploadFileState");  
          uploadFileState.setReadedBytes(readedBytes);  
          uploadFileState.setTotalBytes(totalBytes);  
          uploadFileState.setCurrentItem(currentItem);  
   }  
}
